package com.t20;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * Created by xuyiwei on 2018/9/13.
 */
public class UseCaseTracker {
    public static void trackUseCases(List<Integer> useCases,
                                     Class<?> cl){
        for(Method m :cl.getDeclaredMethods()){
            UseCase useCase = m.getAnnotation(UseCase.class);
            if(useCase!=null){
                System.out.println("Found Use Case :"+useCase.id()+"  "+ useCase.description());
                useCases.remove(new Integer(useCase.id()));
            }
        }
        for(int i:useCases){
            System.out.println("Warning: Missing use case-"+i);
        }
    }

    public static void main(String[] args) {
        List<Integer> useCases = new ArrayList<>();
        Collections.addAll(useCases,47,48,49,50);
        trackUseCases(useCases,PasswordUtils.class);
    }
    /**
     * Found Use Case :47  Passwords must contain at least on numeric
     Found Use Case :48  no description
     Found Use Case :49  New passwords can not equal previously used ones
     Warning: Missing use case-50
     */

}
